<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %><%--
  Created by IntelliJ IDEA.
  User: 86155
  Date: 2021/10/15
  Time: 13:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=UTF-8");
    //更新在线人数
    application.setAttribute("numOfPeop",(Integer)application.getAttribute("numOfPeop")-1);
    //更新人员列表
    String name = (String) session.getAttribute("uname");
    ArrayList<String> peopList = (ArrayList<String>) application.getAttribute("peopList");
    Iterator<String> iterator = peopList.iterator();
    while(iterator.hasNext()){
        if(name.equals(iterator.next())){
            iterator.remove();
            break;
        }
    }
    System.out.println(peopList);
    application.setAttribute("peopList",peopList);
session.invalidate();
response.setHeader("refresh","3;url=index.jsp");%>
退出成功，页面将在3秒后跳转


